package mylogger1



// 往文件里边写日志

type FileLogger struct {
	Level logLevel
	filePath string
	fileName string
	maxFileSize int64
}

// NewFileLogger 构造函数
func NewFileLogger(levelstr, fp, fn string, maxSize int64) *FileLogger {
	LogLevel, err := parseloglevel(levelstr)
	if err != nil {
		panic(err)
	}
	return &FileLogger{
		Level: LogLevel,
		filePath: fp,
		fileName: fn,
		maxFileSize: maxSize,
	}
}

func (f *FileLogger)enable(loglevel logLevel) bool {
	return f.Level <= loglevel
}

func (f *FileLogger)Debug(format string, a ...interface{})  {
	if f.enable(DEBUG) {
		log(DEBUG,format,a...)
	}
}

func (f *FileLogger)Trace(format string, a ...interface{})  {
	if f.enable(TRACE) {
		log(TRACE,format,a...)
	}
}

func (f *FileLogger)Info(format string, a ...interface{}) {
	if f.enable(INFO) {
		log(INFO,format,a...)
	}
}
func (f *FileLogger)Warning(format string, a ...interface{})  {
	if f.enable(WARNING) {
		log(WARNING,format,a...)
	}
}

func (f *FileLogger)Error(format string, a ...interface{}) {
	if f.enable(ERROR) {
		log(ERROR,format,a...)
	}
}
func (f *FileLogger)Fatal(format string, a ...interface{}) {
	if f.enable(FATAL) {
		log(FATAL,format,a...)
	}

}